<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h3>强制更新</h3>
      <p>{{ list }}</p>
      <p>{{ obj }}</p>
      <button @click="fn">btn</button>
    </div>

    <script src="../../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          list: [1, 2, 3],
          obj: {
            a: 3,
            b: 4,
          },
        },
        methods: {
          fn() {
            // this.list.length = 2;
            // this.list[2] = 5;
            // this.obj.c = 5;
            // 强制更新
            // this.$forceUpdate();
            // this.list = [...this.list];
            // this.list = [].concat(this.list);
            // this.obj = { ...this.obj };
            // this.obj = Object.assign({}, this.obj);

            // this.$set(this.obj, "c", 5);
            // this.$set(this.list, 2, 5);
            this.list.splice(2);
          },
        },
      });
    </script>
  </body>
</html>
